package com.sqx.modules.health.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.modules.health.entity.UserAddress;
import com.sqx.modules.health.mapper.UserAddressMapper;
import com.sqx.modules.health.service.IUserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户联系地址	 服务实现类
 * </p>
 *
 * @author gxy
 * @since 2022-04-08
 */
@Service
public class UserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddress> implements IUserAddressService {

    @Autowired
    private UserAddressMapper userAddressMapper;

    @Override
    public UserAddress getDefaultAddress(Long uid) {
        return userAddressMapper.getDefaultAddress(uid);
    }

    @Override
    public Integer setDefaultAddress(Long id, Integer value) {
        return userAddressMapper.setDefaultAddress(id, value);
    }

    @Override
    public List<UserAddress> getAddressByUserId(Long uid) {
        return userAddressMapper.getAddressByUserId(uid);
    }

    /**
     * 删除用户的时候将该用户下的所有地址信息删除
     * @param id
     */
    @Override
    public void delAddressById(Integer id) {
        userAddressMapper.delAddressById(id);
    }
}
